<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="35%"
    :before-close="handleClose"
    append-to-body
  >
    <el-form ref="form" :model="form" :rules="rules">
      <el-row>
        <el-col :span="24">
          <el-form-item prop="reason">
            <el-input placeholder="请输入作废原因" type="textarea" v-model="form.reason"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitForm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import moment from 'moment'

export default {
  name: "",
  components: {},
  props: {},
  data() {
    return {
      dialogVisible: false,
      form: {
        reason: ''
      },
      title: "",
      rules: {
        reason: [
          { required: true, message: "作废原因不能为空", trigger: "blur" },
        ],
      },
    };
  },
  filters: {},
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  beforeDestroy() {},
  methods: {
    add() {
      this.dialogVisible = true;
      this.title = "作废原因";
      this.$nextTick(function () {
        this.$refs.form.resetFields();
      });
    },
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          console.log(this.form);
          this.dialogVisible = false;
        }
      });
    },
    handleClose(done) {
      this.$modal
        .confirm("确认关闭？")
        .then((_) => {
          this.dialogVisible = false;
        })
        .catch((_) => {});
    },
  },
};
</script>

<style scoped lang="scss">
</style>
